#include<stdio.h>
#define SIZE 5

struct Student_type
{
    char name[10];
    int num;
    int age;
    char addr[15];
}stud[SIZE];

int main()
{
    FILE *fp;
    int i;
    printf("Enter data of students:\n");
    for(i=0;i<SIZE;i++)   scanf("%s %d %d %s",stud[i].name,&stud[i].num,&stud[i].age,stud[i].addr);
    if((fp=fopen("stu.dat","wb"))==NULL){
        printf("Cannot open file!\n");
        return 0;
    }
    for(i=0;i<SIZE;i++){
        if(fwrite((char*)&stud[i],sizeof(struct Student_type),1,fp)!=1)   printf("File write error!\n");
    }
    fclose(fp);
    return 0;
}